import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JPanel;


public class PlayerButtonPanel extends JPanel 
{
	static PlayerGUI playerGUI;
	public PlayerButtonPanel(final PlayerGUI playerGUI)
	{
		GridLayout layout = new GridLayout(5,2);
		JButton btnAttack = new JButton("attack");
		JButton btnConnect = new JButton("connect");
		JButton btnHeal = new JButton("heal");
		JButton btnMove = new JButton("move");
		JButton btnWait = new JButton("wait");
		JButton btnEndTurn = new JButton("endTurn");
		JButton btnUpdate = new JButton("update");
		JButton btnLoad = new JButton("load");
		
		
		setLayout(layout);
		add(btnAttack);
		add(btnConnect);
		add(btnHeal);
		add(btnMove);
		add(btnWait);
		add(btnEndTurn);
		add(btnUpdate);
		add(btnLoad);

		
		btnAttack.addActionListener(new ActionListener()
		{

			@Override
			public void actionPerformed(ActionEvent arg0) 
			{
				try {playerGUI.attack();}
				catch (Exception e) 
				{e.printStackTrace();}	
			}
		});
		
		btnConnect.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent arg0)
			{
				PlayerGUI.connect();
			}
		});
		
		btnHeal.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent arg0)
			{
				PlayerGUI.heal();
			}
		});
		
		btnMove.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent arg0)
			{
				try {PlayerGUI.move();}
				catch (Exception e) 
				{e.printStackTrace();}
			}
		});
		
		btnWait.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent arg0)
			{
				try {PlayerGUI.sendWait();} 
				catch (IOException e){e.printStackTrace();}
			}
		});
		
		
		btnEndTurn.addActionListener(new ActionListener()
		{
			@Override
			public void actionPerformed(ActionEvent arg0) 
			{
				playerGUI.endTurn();
			}
		});
	
		btnUpdate.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent arg0)
			{
				PlayerGUI.update();
			}
		});
		
		btnLoad.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent arg0)
			{
				PlayerGUI.loadPlayer();
			}
		});
		

		
	}//end of constructor
}//
